﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace jQuery.Validation.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public sealed class DigitsAttribute : ValidationAttribute
    {
        public const string RegExString = @"^\d+$";

        public DigitsAttribute()
        {
        }

        public override bool IsValid(object value)
        {
            if (value == null)
                return true;

 
            Regex regEx = new Regex(RegExString);
            return regEx.IsMatch(value.ToString());

            
        }
    }
}
